﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DukeySoundHelper.API;

using MHook;

namespace DukeySoundHelper
{
    public partial class ConfigFrm : Form
    {
        public ConfigFrm()
        {
            InitializeComponent();
        
        }

        private void txtBackColor_MouseClick(object sender, MouseEventArgs e)
        {
            if (DialogResult.OK == colorDialog1.ShowDialog())
            {
                txtBackColor.Text = DukeyComm.ColorToHex(colorDialog1.Color);
            }
        }

        private void btnTop_Click(object sender, EventArgs e)
        {
            txtwinpopLeft.Text = (Screen.PrimaryScreen.WorkingArea.Width / 2 - 300).ToString();
            txtwinpopTop.Text = "0";
        }

        private void btnMiddle_Click(object sender, EventArgs e)
        {
            txtwinpopLeft.Text = (Screen.PrimaryScreen.WorkingArea.Width / 2 - 300).ToString();
            txtwinpopTop.Text = (Screen.PrimaryScreen.WorkingArea.Height / 2 - 47).ToString();
        }

        private void btnBottom_Click(object sender, EventArgs e)
        {
            txtwinpopLeft.Text = (Screen.PrimaryScreen.WorkingArea.Width / 2 - 300).ToString();
            txtwinpopTop.Text = (Screen.PrimaryScreen.WorkingArea.Height - 94).ToString();
        }
        MHook.KeyboardHook keyHook = new MHook.KeyboardHook();
        MHook.MouseHook mousehook = new MHook.MouseHook();
        private void btnSetHotKeys_Click(object sender, EventArgs e)
        {
            //keyHook.KeyDown += new MHook.KBEventHandler(keyHook_KeyDown);
            //keyHook.Hook();

            //mousehook.MouseButtonDown += new MHook.MouseHookEventHandler(mousehook_MouseButtonDown);
            //mousehook.Hook();

        }

        bool mousehook_MouseButtonDown(MHook.MouseHookEventArgs e)
        {

            return true;
        }

        bool keyHook_KeyDown(Keys key)
        {

            if (key == Keys.LControlKey)
            {
                //btnSetHotKeys.Text = key.ToString() + "+";
            }
            return true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            mousehook.Unhook();
            keyHook.Unhook();
        }

   

        private void txthot1_KeyPress(object sender, KeyPressEventArgs e)
        {
            //txthot1.Text = e.KeyChar.ToString();
        }

        private void txtVolumeUp_KeyUp(object sender, KeyEventArgs e)
        {
           
        }

        private void txtVolumeUp_KeyDown(object sender, KeyEventArgs e)
        {
            //txtVolumeUp.Text = e.KeyData.ToString();
            //if (e.Control)
            //{

            //    txtVolumeUp.Text = "Ctrl + ";
            //}
            //if (e.Alt)
            //{
            //    txtVolumeUp.Text = "Alt + ";
            //}
            //if (e.Shift)
            //{
            //    txtVolumeUp.Text = "Shift + ";
            //}
           
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            MyConfig.Instance.IsMouseLeftUp = chkLeftUp.Checked;
            MyConfig.Instance.IsMouseLeftDown = chkLeftDown.Checked;
            MyConfig.Instance.IsMouseRightUp = chkRightUp.Checked;
            MyConfig.Instance.IsMouseRightDown = chkRightDown.Checked;
            MyConfig.Instance.IsMouseMiddleUp = chkMiddleUp.Checked;
            MyConfig.Instance.IsMouseMiddleDown = chkMiddleDown.Checked;
            MyConfig.Instance.IsMouseLeftRight = chkLeftRight.Checked;
            MyConfig.Instance.IsMouseRightLeft = chkRightLeft.Checked;
            MyConfig.Instance.IsMouseRightMiddle = chkRightMiddle.Checked;
            MyConfig.Instance.Highkeys = new KeyValuePair<Keys, Keys>(txthotkeyup.HotkeyModifiers, txthotkeyup.Hotkey);
            MyConfig.Instance.Lowkeys = new KeyValuePair<Keys, Keys>(txtHotkeyDown.HotkeyModifiers, txtHotkeyDown.Hotkey);
            MyConfig.Instance.Mutekeys = new KeyValuePair<Keys, Keys>(txtHotkeyMute.HotkeyModifiers, txtHotkeyMute.Hotkey);     


            //MyConfig.Instance.Highkeys=

            txthotkeyup.HotkeyModifiers = Keys.ControlKey;
            //MessageBox.Show(txthotkeyup.HotkeyModifiers);
           
            //KeyValuePair<Keys,Keys> pair= new KeyValuePair<Keys,Keys>(txthotkeyup.HotkeyModifiers, txthotkeyup.Hotkey);
            //MyConfig.Instance.Highkeys = pair;
            //this.Hide();
        }







    }
}
